package bulletbehavior 
{
	import org.flixel.FlxG;
	/**
	 * ...
	 * @author morgan
	 */
	public class AccelerateRelativeBehavior extends BulletBehavior
	{
		public var accelSide:Number;
		public var accelForward:Number;
		public function AccelerateRelativeBehavior(accelForward:Number = 50, accelSide:Number = 0)
		{
			this.accelForward = accelForward;			
			this.accelSide = accelSide;
		}
		
		override public function onUpdate(b:Bullet):void 
		{
			super.onUpdate(b);

			var vx:Number = b.velocity.x;
			var vy:Number = b.velocity.y;
			var d:Number = Math.sqrt(vx * vx + vy * vy);
			vx /= d;
			vy /= d;
			b.velocity.x += vx * accelForward * FlxG.elapsed;
			b.velocity.y += vy * accelForward * FlxG.elapsed;
			b.velocity.x += vy * accelSide * FlxG.elapsed;
			b.velocity.y += vx * accelSide * FlxG.elapsed;			
			
		}
		
	}

}